/**
 * 
 */
package org.student.impl;

import java.util.List;

import org.springframework.stereotype.Component;
import org.student.dao.IScoreDao;
import org.student.entity.StuSys_Score;
import org.student.entity.StuSys_Teacher;

@Component("IScoreDaoImpl")
public class IScoreDaoImpl extends HibernateDaoImpl implements IScoreDao {

	/** 
	 */
	@Override
	public boolean insertScore(StuSys_Score sco) throws Exception {
		super.getHibernateTemplate().save(sco);
		return true;
	}
	/**
	 */
	
	
	/**
	 */
	@Override
	public List<StuSys_Score> getScoresByName(String name) throws Exception {
		
		return (List<StuSys_Score>) super.getHibernateTemplate().find(
				"from StuSys_Score where scoreName = '%" + name + "%'");
	}
	
	@Override
	public List<StuSys_Score> getScoreByStudentName(String stuName)
			throws Exception {
		return (List<StuSys_Score>) super.getHibernateTemplate().find("from StuSys_Score where student.stuName like '%" + stuName+ "%'");
	}
	@Override
	public List<StuSys_Score> getScoreByStudentId(int id)
			throws Exception {
		return (List<StuSys_Score>) super.getHibernateTemplate().find("from StuSys_Score where student.id = '" + id+ "'");
	}
	@Override
	public void deleteScore(int id) throws Exception {
		this.delete(StuSys_Score.class, id) ;
		
	}
	@Override
	public void updateScore(StuSys_Score sco) throws Exception {
		this.update(sco);
		
	}
	public List<StuSys_Score> getAllScore() throws Exception {
		
		return (List<StuSys_Score>) super.getHibernateTemplate().find("from StuSys_Score");
	}
	public List<StuSys_Score> getScoreById(String id) throws Exception {
		
		return (List<StuSys_Score>) super.getHibernateTemplate().find("from StuSys_Score where id = " + id);
			
	}
	
}
